<?php

namespace app\api\controller;


use app\common\controller\Api;
use app\model\Banner;
use app\admin\model\Orders;

use app\model\User;
/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    public function getSys(){
        $data = db('config')->where('group','basic')->where("can_set",1)->select();
        $sysData = [];
        foreach ($data as $item){
            $sysData[$item['name']] = $item['value'];
        }
        $sysData = $this->formateDataBylang($sysData,['name','address'],false);
        $sysData['address'] = str_replace('<br/>',' ',$sysData['address']);
        $this->success('ok',$sysData);
    }
    public function getBanner(){
        $bannerData = (new Banner())->where('status',1)->where('type',2)->select();
        $this->success('ok',$bannerData);
    }
    public function getPhone(){
        $orderModel = new Orders();
        $token = getHeaderToken();
        $tokenData = getJWT($token);
        if(empty($tokenData['id'])){
            $this->error('未登录',[]);
        }
        $orderData = $orderModel->where("user_id",$tokenData['id'])->where('status',$orderModel::STATUS_HASPAY)->select();
        $this->success('ok',$orderData);
    }

}
